<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="apple-mobile-web-app-title" content="沙盘操控">
    <meta name="mobile-web-app-capable" content="yes">
    <title>沙盘远程操控系统</title>
    <link rel="stylesheet" href="css/mobile.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            height: 100vh;
            overflow: hidden;
        }

        .container {
            display: flex;
            flex-direction: column;
            height: 100vh;
        }

        .header {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            padding: 15px 20px;
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        }

        .title {
            font-size: 24px;
            font-weight: bold;
        }

        .status {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .status-indicator {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: #ff4444;
            transition: background 0.3s;
        }

        .status-indicator.connected {
            background: #44ff44;
        }

        .main-content {
            flex: 1;
            display: flex;
            gap: 20px;
            padding: 20px;
        }

        .sandbox-area {
            flex: 1;
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            overflow: hidden;
            position: relative;
        }

        #sandbox-canvas {
            width: 100%;
            height: 100%;
            display: block;
            cursor: crosshair;
        }

        .control-panel {
            width: 300px;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-radius: 15px;
            padding: 20px;
            color: white;
        }

        .control-section {
            margin-bottom: 25px;
        }

        .control-section h3 {
            margin-bottom: 15px;
            font-size: 18px;
            color: #fff;
        }

        .control-button {
            width: 100%;
            padding: 12px;
            margin-bottom: 10px;
            background: rgba(255, 255, 255, 0.2);
            border: none;
            border-radius: 8px;
            color: white;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
        }

        .control-button:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: translateY(-2px);
        }

        .control-button:active {
            transform: translateY(0);
        }

        .slider-container {
            margin-bottom: 15px;
        }

        .slider-label {
            display: block;
            margin-bottom: 5px;
            font-size: 14px;
        }

        .slider {
            width: 100%;
            height: 6px;
            border-radius: 3px;
            background: rgba(255, 255, 255, 0.3);
            outline: none;
            -webkit-appearance: none;
        }

        .slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: #fff;
            cursor: pointer;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
        }

        .coordinates {
            background: rgba(0, 0, 0, 0.1);
            padding: 10px;
            border-radius: 8px;
            font-family: monospace;
            font-size: 14px;
        }

        /* iPad 优化 */
        @media (max-width: 1024px) {
            .main-content {
                flex-direction: column;
                gap: 15px;
                padding: 15px;
            }

            .control-panel {
                width: 100%;
                order: -1;
            }

            .control-section {
                display: inline-block;
                width: 48%;
                margin-right: 2%;
                vertical-align: top;
            }

            .title {
                font-size: 20px;
            }
        }

        /* 手机优化 */
        @media (max-width: 768px) {
            .header {
                padding: 10px 15px;
            }

            .title {
                font-size: 18px;
            }

            .control-section {
                width: 100%;
                margin-right: 0;
            }

            .main-content {
                padding: 10px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="title">沙盘远程操控系统</div>
            <div class="status">
                <span>连接状态:</span>
                <div class="status-indicator" id="status-indicator"></div>
                <span id="status-text">未连接</span>
            </div>
        </div>

        <div class="main-content">
            <div class="sandbox-area">
                <canvas id="sandbox-canvas"></canvas>
            </div>

            <div class="control-panel">
                <div class="control-section">
                    <h3>连接控制</h3>
                    <button class="control-button" id="connect-btn">连接服务器</button>
                    <button class="control-button" id="disconnect-btn" disabled>断开连接</button>
                </div>

                <div class="control-section">
                    <h3>沙盘操作</h3>
                    <button class="control-button" id="clear-btn">清空沙盘</button>
                    <button class="control-button" id="reset-btn">重置视图</button>
                </div>

                <div class="control-section">
                    <h3>绘制设置</h3>
                    <div class="slider-container">
                        <label class="slider-label">画笔大小: <span id="brush-size-value">5</span></label>
                        <input type="range" class="slider" id="brush-size" min="1" max="20" value="5">
                    </div>
                    <div class="slider-container">
                        <label class="slider-label">透明度: <span id="opacity-value">100%</span></label>
                        <input type="range" class="slider" id="opacity" min="10" max="100" value="100">
                    </div>
                </div>

                <div class="control-section">
                    <h3>坐标信息</h3>
                    <div class="coordinates">
                        <div>X: <span id="coord-x">0</span></div>
                        <div>Y: <span id="coord-y">0</span></div>
                        <div>操作: <span id="action-type">无</span></div>
                    </div>
                </div>

                <div class="control-section">
                    <h3>快捷操作</h3>
                    <button class="control-button" id="fullscreen-btn">全屏模式</button>
                    <button class="control-button" id="add-building-btn">添加建筑</button>
                    <button class="control-button" id="add-tree-btn">添加树木</button>
                </div>
            </div>
        </div>
    </div>

    <script src="js/device-detector.js"></script>
    <script src="js/sandbox.js"></script>
    <script src="js/websocket.js"></script>
    <script src="js/main.js"></script>
</body>
</html>